apiVersion: apps/v1
kind: Deployment
metadata:
  name: consumer-server-deployment
  labels:
    app: consumer-server
spec:
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  selector:
    matchLabels:
      app: consumer-server
  template:
    metadata:
      labels:
        app: consumer-server
    spec:
      containers:
        - name: consumer-server
          image: dmitrykaplan/consumer-server:1
          env:
            - name: POSTGRES_QUARTZ_HOST
              valueFrom:
                secretKeyRef:
                  name: postgres-quartz-secret
                  key: POSTGRES_HOST

            - name: POSTGRES_QUARTZ_DB
              valueFrom:
                secretKeyRef:
                  name: postgres-quartz-secret
                  key: POSTGRES_DB

            - name: POSTGRES_QUARTZ_PORT
              valueFrom:
                secretKeyRef:
                  name: postgres-quartz-secret
                  key: POSTGRES_PORT

            - name: POSTGRES_QUARTZ_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-quartz-secret
                  key: POSTGRES_USER

            - name: POSTGRES_QUARTZ_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-quartz-secret
                  key: POSTGRES_PASSWORD
          envFrom:
            - secretRef:
                name: rabbit-mq-secret
            - secretRef:
                name: postgres-consumer-secret
            - configMapRef:
                name: consumer-server-config-map
          ports:
            - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: consumer-server-service
  labels:
    app: consumer-server
spec:
  selector:
    app: consumer-server
  ports:
    - port: 3002
      targetPort: 8080
  type: ClusterIP
